<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:pn="http://stager.uninett.no/perfsonarnc/1.0"
    xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
    xmlns:netutil="http://ggf.org/ns/nmwg/characteristic/utilization/2.0/"
    xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/" xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <soapenv:Envelope>
            <soapenv:Body>
                <nmwg:message type="MetadataKeyResponse">
                    <xsl:for-each select="//pn:obsPoint">
                        <nmwg:metadata id="meta{pn:id}">
                            <netutil:subject id="subj{pn:id}">
                                <nmwgt:interface>
                                    <nmwgt:hostName>
                                        <xsl:value-of select="pn:hostname"/>
                                    </nmwgt:hostName>
                                    <nmwgt:ifName>
                                        <xsl:value-of select="pn:name"/>
                                    </nmwgt:ifName>
                                    <nmwgt:direction>
                                        <xsl:value-of select="pn:direction"/>
                                    </nmwgt:direction>
                                    <nmwgt:capacity>
                                        <xsl:value-of select="pn:capacity"/>
                                    </nmwgt:capacity>
                                    <nmwgt:ifAddress>
                                        <xsl:value-of select="pn:ipaddress"/>
                                    </nmwgt:ifAddress>                                
                                    <nmwgt:ifDescription>
                                        <xsl:if test="pn:direction='in'">ifHCInOctets</xsl:if>
                                        <xsl:if test="pn:direction='out'">ifHCOutOctets</xsl:if>
                                    </nmwgt:ifDescription>
                                </nmwgt:interface>
                            </netutil:subject>
                            <nmwg:eventType>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>
                            <nmwg:eventType>http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:eventType>
                        </nmwg:metadata>
                    </xsl:for-each>
                    <xsl:for-each select="//pn:obsPoint">
                        <nmwg:data id="data{pn:id}" metadataIdRef="meta{pn:id}">
                            <nmwg:key>
                                <nmwg:parameters>
                                    <nmwg:parameter name="file">private</nmwg:parameter>
                                    <nmwg:parameter name="dataSource">ds0</nmwg:parameter>
                                    <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
                                    <nmwg:parameter name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
                                    <nmwg:parameter name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
                                </nmwg:parameters>
                            </nmwg:key>
                        </nmwg:data>
                    </xsl:for-each>
                </nmwg:message>
            </soapenv:Body>
        </soapenv:Envelope>
    </xsl:template>
</xsl:stylesheet>
